export const roundRect = (ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r = 4) => {
  if (w < 2 * r) {
    r = w / 2;
  }
  if (h < 2 * r) {
    r = h / 2;
  }
  ctx.save()
  ctx.beginPath();
  ctx.moveTo(x + r, y);
  ctx.arcTo(x + w, y, x + w, y + h, r);
  ctx.arcTo(x + w, y + h, x, y + h, r);
  ctx.arcTo(x, y + h, x, y, r);
  ctx.arcTo(x, y, x + w, y, r);
  ctx.closePath();
  ctx.restore()
  return ctx;
};

export const isInRect = (leftTop: {x: number, y: number}, width: number, height: number, point : {x: number, y: number}) => {
  if (point.x >= leftTop.x && point.x <= leftTop.x + width && point.y >= leftTop.y && point.y <= leftTop.y + height) {
    return true
  }
  return false
}